package com.bajiao.app.controller.appVersion;

import com.bajiao.app.base.AppBaseController;
import com.bajiao.common.api.vo.RestResult;
import com.bajiao.common.aspect.annotation.AutoLog;
import com.bajiao.common.menu.ResultEnum;
import com.bajiao.service.appVersion.VersionService;
import com.bajiao.vo.app.VersionVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description: app版本更新记录表
 * @Author: FanJq
 * @Date: 2024-10-10
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "app版本更新记录表")
@RestController
@RequestMapping("/api/v1/app/version")
public class RestVersionController extends AppBaseController {

    @Autowired
    private VersionService versionService;

    /**
     * @description: 获取指定终端最近版本记录
     * @author: FanJq
     * @date: 2024-10-10
     * @param type APP类型 1：安卓   2：ios
     * @return: com.bajiao.common.api.vo.RestResponseBean
     */
    @AutoLog(value = "获取指定终端最近版本记录")
    @RequestMapping(value = "/queryLastVersion")
    public RestResult<VersionVO> queryLastVersion(@RequestParam("type") Integer type) {
        VersionVO versionVO = versionService.queryLastVersion(type);
        if (versionVO == null) {
            return fail(ResultEnum.QUERY_NOT_EXIST.getDesc());
        }
        return success(ResultEnum.QUERY_SUCCESS.getDesc(),versionVO);
    }


}
